What is @babel/plugin-syntax-nullish-coalescing-operator?
The @babel/plugin-syntax-nullish-coalescing-operator package allows Babel to parse code that uses the nullish coalescing operator (??). This operator is a logical operator that returns its right-hand side operand when its left-hand side operand is null or undefined, and otherwise returns its left-hand side operand. This package does not transform the nullish coalescing syntax; it only enables Babel to understand it.
Parsing nullish coalescing operator
This code demonstrates how the nullish coalescing operator is used to provide a default value ('default string') in case the left-hand operand (foo) is null or undefined.
const foo = null ?? 'default string';